/**
 * FileName: BaseFrom
 * Author: Mr.Wang
 * Date: 2025/10/17 08:36
 * Description:
 * History:
 */
package org.test.device.architecture.from;

import jakarta.validation.constraints.NotNull;
import lombok.Data;
import org.springframework.beans.BeanUtils;
import org.test.device.architecture.CommonEntity;

import java.util.function.Supplier;

/**
 * 〈一句话功能简述〉<br>
 * 〈〉
 *
 * @author Mr.Wang
 * @create 2025/10/17
 * @since 1.0.0
 */
@Data
public class BaseFrom {

    private String id;

    public <T extends CommonEntity> T toPo(@NotNull final Supplier<? extends T> ctor) {
        final T po = ctor.get();
        BeanUtils.copyProperties(this, po);
        return po;
    }
}